//
//  ForgetPasswordController.m
//  CaiPiao
//
//  Created by l wb on 2018/5/17.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ForgetPasswordController.h"

@interface ForgetPasswordController ()
@property (weak, nonatomic) IBOutlet UITextField *emailTF;

@end

@implementation ForgetPasswordController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (IBAction)forgetPasswordClickAction:(UIButton *)sender {
    if (![self  isValidateEmail:self.emailTF.text]){
        
        [EasyTextView showInfoText:@"请输入正确的邮箱地址"];
        return;
    }
    [BmobUser requestPasswordResetInBackgroundWithEmail:self.emailTF.text];
    [EasyTextView showText:@"重置密码邮件已发送至你的邮箱"];
    [self.navigationController popViewControllerAnimated:YES];
    
    
}

-(BOOL)isValidateEmail:(NSString *)email {
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:email];
}


@end
